import { createApp } from "vue";
import "./style.css";

import ElementPlus from "element-plus";
import "element-plus/dist/index.css"; // 导入element的样式

import locale from "element-plus/es/locale/lang/zh-cn";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

import VueCookies from "vue-cookies";
import router from "@/router/index";
import App from "./App.vue";
import Verify from "@/utils/verify";
import { createPinia } from "pinia";
import { createPersistedState } from "pinia-persistedstate-plugin";
// 生成二维码
import VueQrcode from "vue-qrcode";
import Icon from "@/components/Icon.vue";
//svg插件需要配置代码
import "virtual:svg-icons-register";

// 自定义组件
import Dialog from "@/components/Dialog.vue";
import Avatar from "@/components/Avatar.vue";
import Table from "@/components/Table.vue";
import Drawer from "@/components/Drawer.vue";
import ImagePreview from "@/components/ImagePreview/index.vue";
import Pagination from "@/components/Pagination/index.vue";
import ImageUpload from "@/components/ImageUpload/index.vue";
import InputSelect from "@/components/InputSelect/index.vue";
import FileUpload from "@/components/FileUpload/index.vue";
import SimpleTag from "@/components/Tag/simpleTag.vue";
import TableTag from "@/components/Tag/tableTag.vue";
import FilePreviewTable from "@/components/FilePreview/table.vue";
// 视频播放

const app = createApp(App);

// 全局方法
app.config.globalProperties.Verify = Verify;
app.config.globalProperties.VueCookies = VueCookies;
// 全局组件挂载
app
  .component("Dialog", Dialog)
  .component("Table", Table)
  .component("Avatar", Avatar)
  .component("Drawer", Drawer)
  .component("ImagePreview", ImagePreview)
  .component("Icon", Icon)
  .component("Pagination", Pagination)
  .component("ImageUpload", ImageUpload)
  .component("InputSelect", InputSelect)
  .component("vue-qrcode", VueQrcode)
  .component("FileUpload", FileUpload)
  .component("SimpleTag", SimpleTag)
  .component("TableTag", TableTag)
  .component("FilePreview-table", FilePreviewTable);

const pinia = createPinia();
const persist = createPersistedState();
app.use(VueCookies);
app.use(router);

// 全局注册element图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(ElementPlus, { locale }); // 使用element-plus
pinia.use(persist);
app.use(pinia);
// 提供 router   便于全局使用
// app.provide("router", router);

app.mount("#app");
